package com.stsmobile.dataclass;

import java.util.ArrayList;
import java.util.Collection;

/**
 * Data wrapper class for a shipment. Contains an ArrayList of Specimens.
 * @author Dave
 *
 */
public class Shipment 
{
	//---State Variables---//
	private String shipment_id, institution, lab, shipStatus, shipDate, receiveDate;
	private ArrayList<Specimen> mySpecimens;
	
	@Override
	public String toString(){
		return "Shipment ID: "+shipment_id+"\n"+"Institution: "+institution+"\n"+
		"Lab: "+lab+"\n"+"Status: "+shipStatus+"\n"+"Shipped on: "+shipDate+"\n"+
		"Received on: "+receiveDate+"\n"+"Specimens: "+mySpecimens.toString()+"\n";
	}

	
	//---Creating the Shipment---//
	/**
	 * Creates a Shipment with the desired characteristics.
	 * @param ship_id
	 * @param institution_name
	 * @param lab_name
	 * @param ship_status
	 * @param ship_date
	 * @param receive_date
	 */
	public Shipment(String ship_id, String institution_name, String lab_name, 
			String ship_status, String ship_date, String receive_date)
	{
		shipment_id=ship_id;
		institution=institution_name;
		lab=lab_name;
		shipStatus=ship_status;
		shipDate=ship_date;
		receiveDate=receive_date;
		
		mySpecimens = new ArrayList<Specimen>();
	}

	
	//---Specimen List Methods---//
	/**
	 * Adds a single specimen object to the shipment.
	 * @param s
	 * @return
	 */
	public boolean addSpecimen(Specimen s){
		return mySpecimens.add(s);
	}
	
	/**
	 * Adds an existing collection of specimens to the shipment.
	 * @param specs
	 * @return
	 */
	public boolean addSpecimen(Collection<? extends Specimen> specs){
		return mySpecimens.addAll(specs);
	}
	
	/**
	 * Gets a specific specimen from shipment.
	 * @param spec_id
	 * @return The specimen specified by spec_id or null if such a specimen is not in the shipment.
	 */
	public Specimen getSpecimen(int spec_id){
		for (Specimen s: mySpecimens){
			if(s.getSpecimenID()==spec_id)
				return s;
		}
		return null;
	}
	

	/**
	 * Grabs a list of all the specimens in Shipment.
	 * @return the list of specimens in Shipment.
	 */
	public ArrayList<Specimen> getSpecimenList() {
		return mySpecimens;
	}
	
	
	//---Getters/Setters---//
	public String getShipment_id() {
		return shipment_id;
	}

	public String getInstitution() {
		return institution;
	}

	public String getLab() {
		return lab;
	}

	public String getShipStatus() {
		return shipStatus;
	}

	public String getShipDate() {
		return shipDate;
	}

	public String getReceiveDate() {
		return receiveDate;
	}
	
	public void wipeData(){
		shipment_id="NONE";
		institution="-";
		lab="-";
		shipStatus="NO SHIPMENT SELECTED";
		shipDate="-";
		receiveDate="-";
		
		mySpecimens = new ArrayList<Specimen>();
	}
	
}
